package com.kiwiplan;

import org.apache.log4j.Logger;




/**
 * This util class is used deal with number with kiwiplan
 * @author jason.zhang
 *
 */
public class KiwiplanNumberUtil {

	// use ZERO insteand of 0
	private final static int ZERO = 0;
	// this is the log of log4j 
	private final static Logger  logger = Logger.getLogger(KiwiplanNumberUtil.class);
	
	/**
	 * return the sum of the number in the arr
	 * @param numberArr
	 * @return
	 */
	public static int sumNumbers(int[] numberArr){
		if(numberArr == null ){
			logger.error(" wrong argument");
			throw new IllegalArgumentException("argument can not be null");
		}
		if(numberArr.length == ZERO){
			return 0;
		}
		if(numberArr.length >10){
			throw new IllegalArgumentException("the length can not be longer than 10");
		}
		
		int sum = 0;
		for(int number:numberArr){
			sum += number;
		}
		
		return sum;
	}
}
